<?php

namespace frontend\models\login;

use Yii;
use yii\base\Model;
use frontend\models\User;

/**
 * ContactForm is the model behind the contact form.
 */
class LoginForm extends User
{
	public $rememberMe = true;


	public static function tableName()
    {
        return 'edu_user';
    }
    /**
     * @inheritdoc 验证规则
     */
    public function rules()
    {
        return [
			[['user_name','user_pwd'], 'required','message'=>'当前项不能为空'],
            [['user_name'], 'string', 'max' => 18],
            [['user_pwd'], 'string', 'min'=>6, 'max' => 16,'tooLong'=>'密码不得多于16位', 'tooShort'=>'密码不得少于6位'],
			['rememberMe', 'boolean'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'user_name' => '',
            'user_pwd' => '',
			'rememberMe' => '下次直接登录',
        ];
    }
	/*
	*	验证用户名，密码，邮箱
	*/
	public	function getUserName($user_name)
	{
		 return $this->find()->where(['or',['user_name'=>$user_name],['user_phone'=>$user_name],['user_email'=>$user_name]])->asarray()->one();
	}
}